//
//  UIView+Frame.m
//  hcpro
//
//  Created by 戴旭 on 16/9/15.
//  Copyright © 2016年 hucai.com. All rights reserved.
//

#import "UIView+Frame.h"


@implementation UIView (Frame)

- (CGFloat)hc_x {
    return self.frame.origin.x;
}

- (void)setHc_x:(CGFloat)x{
    CGRect frame = self.frame;
    frame.origin.x = x;
    [self setFrame:frame];
}

- (CGFloat)hc_y {
    return self.frame.origin.y;
}

- (void)setHc_y:(CGFloat)y {
    CGRect frame = self.frame;
    frame.origin.y = y;
    [self setFrame:frame];
}

- (CGFloat)hc_maxX {
    return self.frame.origin.x + self.frame.size.width;
}

- (void)setHc_maxX:(CGFloat)maxX {
    CGRect frame = self.frame;
    frame.origin.x = maxX - frame.size.width;
    [self setFrame:frame];
}

- (CGFloat)hc_maxY {
    return self.frame.origin.y + self.frame.size.height;
}

- (void)setHc_maxY:(CGFloat)maxY {
    CGRect frame = self.frame;
    frame.origin.y = maxY - frame.size.height;
    [self setFrame:frame];
}

- (CGFloat)hc_centerX {
    return self.center.x;
}

- (void)setHc_centerX:(CGFloat)centerX {
    self.center = CGPointMake(centerX, self.center.y);
}

- (CGFloat)hc_centerY {
    return self.center.y;
}

- (void)setHc_centerY:(CGFloat)centerY {
    self.center = CGPointMake(self.center.x, centerY);
}

- (CGFloat)hc_width {
    return self.frame.size.width;
}

- (void)setHc_width:(CGFloat)width {
    CGRect frame = self.frame;
    frame.size.width = width;
    [self setFrame:frame];
}

- (CGFloat)hc_height {
    return self.frame.size.height;
}

- (void)setHc_height:(CGFloat)height {
    CGRect frame = self.frame;
    frame.size.height = height;
    [self setFrame:frame];
}

- (CGPoint)hc_origin {
    return self.frame.origin;
}

- (void)setHc_origin:(CGPoint)origin {
    CGRect frame = self.frame;
    frame.origin = origin;
    [self setFrame:frame];
}

- (CGSize)hc_size {
    return self.frame.size;
}

- (void)setHc_size:(CGSize)size {
    CGRect frame = self.frame;
    frame.size = size;
    [self setFrame:frame];
}

- (CGFloat)hc_orientationWidth {
    return UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)
    ? self.hc_height : self.hc_width;
}

- (CGFloat)hc_orientationHeight {
    return UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)
    ? self.hc_width : self.hc_height;
}

@end
